package main

import (
	"log"
	"os"
	"strings"

	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/widget"
	"github.com/flopp/go-findfont"
)

func init() {
	//设置中文环境
	fontPaths := findfont.List()
	for _, path := range fontPaths {

		//楷体:simkai.ttf
		//黑体:simhei.ttf
		if strings.Contains(path, "simhei.ttf") {
			log.Println("设置字体路径=", path)
			os.Setenv("FYNE_FONT", path)
			break
		}
		//mac
		if strings.Contains(path, "Arial Unicode.ttf") {
			log.Println("设置字体路径=", path)
			os.Setenv("FYNE_FONT", path)
			break
		}
		//mac
		if strings.Contains(path, "Apple Braille.ttf") {
			log.Println("设置字体路径=", path)
			os.Setenv("FYNE_FONT", path)
			break
		}

	}
}

func main() {
	a := app.New()
	w := a.NewWindow("SysTray")

	w.SetContent(widget.NewLabel("Fyne Starter"))
	w.SetCloseIntercept(func() {
		w.Hide()
	})

	w.ShowAndRun()
}
